#include <iostream>
using namespace std;

class Base
{
public:
    virtual void getArea() = 0;
    virtual void getPerimeter() = 0;
};

class Circle : public Base
{
public:
    Circle(double r)
    {
        radius = r;
    }
    void getArea()
    {
        cout << "圆的面积是: " << 3.14 * radius * radius << endl;
    }
    void getPerimeter()
    {
        cout << "圆的周长是: " << 2 * 3.14 * radius << endl;
    }

private:
    double radius;
};

class InCircle : public Base
{
public:
    InCircle(double r)
    {
        length = 1.414 * r;
    }
    void getArea()
    {
        cout << "内接正方形的面积是: " << length * length << endl;
    }
    void getPerimeter()
    {
        cout << "内接正方形的周长是: " << 4 * length << endl;
    }

private:
    double length;

};

class OutCircle : public Base
{
public:
    OutCircle(double r)
    {
        length = 2 * r;
    }
    void getArea()
    {
        cout << "外接正方形的面积是: " << length * length << endl;
    }
    void getPerimeter()
    {
        cout << "外接正方形的周长是: " << 4 * length << endl;
    }
private:
    double length;
};

int main()
{
    InCircle in(5);
    OutCircle out(5);
    Circle circle(5);

    Base *p[3];
    p[0] = &in;
    p[1] = &out;
    p[2] = &circle;

    for (int i = 0; i < 3; i++)
    {
        p[i]->getArea();
        p[i]->getPerimeter();
    }


    return 0;
}